#include "stdafx.h"
#include "Camera.h"

namespace Cvekas {

SimpleCamera::SimpleCamera(const Vector3 &pos, const Vector3 &dir, const Vector3 &up)
	: pos(pos), dir(dir), up(up), rebuild_matrix(true)
{
}

Matrix SimpleCamera::getViewMatrix() const
{
	if(rebuild_matrix)
	{
		view = Matrix::lookAt(pos, pos + dir, up);
		rebuild_matrix = false;
	}

	return view;
}

Vector3 SimpleCamera::getPosition() const
{
	return pos;
}

Vector3 SimpleCamera::getDirection() const
{
	return dir;
}

Vector3 SimpleCamera::getUp() const
{
	return up;
}

void SimpleCamera::setPosition(const Vector3& pos)
{
	rebuild_matrix = true;
	this->pos = pos;
}

void SimpleCamera::setDirection(const Vector3& dir)
{
	rebuild_matrix = true;
	this->dir = dir;
}

void SimpleCamera::setUp(const Vector3& up)
{
	rebuild_matrix = true;
	this->up = up;
}

} // namespace